<template>
  <div>
    <TitleName
      v-if="props.showTitle"
      title="验收列表"
      icon="i-carbon-bookmark-filled"
      class="title"
    ></TitleName>
    <el-table :data="acceptanceTableList" class="mt-15px" border>
      <el-table-column label="阶段" prop="stage" :show-overflow-tooltip="true">
      </el-table-column>
      <el-table-column label="期数" prop="periodsNum" width="80">
      </el-table-column>
      <el-table-column label="计划验收日期" prop="planAccepDate" width="130">
        <template #default="scope">
          <span>{{ parseTime(scope.row.planAccepDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="计划验收占比(%)"
        prop="planAccepRatio"
        width="130"
      />
      <el-table-column
        label="计划回款金额(元)"
        prop="planReturnSum"
        width="130"
      />
      <el-table-column label="实际验收时间" width="130">
        <template #default="scope">
          <span>{{ parseTime(scope.row.actAccepTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="验收附件">
        <template #default="scope">
          <div
            class="text-12px text-#1890ff pointer"
            v-if="scope.row.fileName"
            @click.prevent="fileClink(scope.row)"
          >
            {{ scope.row.origFileName }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="备注"
        prop="remark"
        :show-overflow-tooltip="true"
      />
    </el-table>
  </div>
</template>

<script setup name="Acceptance">
import { getCurrentInstance } from 'vue'
import { useRouter } from 'vue-router'
import ContractStatuDialog from './contractStatuDialog.vue'
import {
  project_phase, //项目阶段
  project_properties, //项目属性
  business_attribute, //业务属性
  contract_status
} from '@/hooks/dict/useProject'
import { addDownloadLog } from '@/api/fileManage'
const router = useRouter()
const { proxy } = getCurrentInstance()
// 接受父级传递的参数
const props = defineProps({
  // 验收列表
  acceptanceTable: {
    required: true,
    type: Object || Array,
    default: () => {
      return {}
    }
  },
  // 是否显示标题
  showTitle: {
    required: false,
    type: Boolean,
    default: true
  }
})
watchEffect(
  () => {
    acceptanceTableList.value = [...props.acceptanceTable]
  },
  {
    flush: 'post'
  }
)

const data = reactive({
  //验收列表
  acceptanceTableList: []
})
const { acceptanceTableList } = toRefs(data)
//预览
const fileClink = row => {
  const path = row.fileUrl
  if (path) {
    window.open(path, '_blank')
    addDownloadLog({ fileId: row.fileId })
  }
}
</script>

<style scoped lang="scss"></style>
